package learning.numbers.pro;




import android.app.Activity;
import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.net.Uri;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.view.WindowManager;
import android.view.View.OnTouchListener;
import android.widget.ImageView;
import android.widget.TextView;


public class MainMenuActivity extends Activity{
	
	OnTouchListener l;
	TextView start,learn,exit,more;
	ViewGroup parent;
	ImageView title;
	public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);    
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
        setContentView(R.layout.main);         
       
        parent = (ViewGroup) findViewById(R.id.main_menu_relativelayout);
        
        l = new OnTouchListener() {
			
			@Override
			public boolean onTouch(View v, MotionEvent event) {
				if (event.getAction() == MotionEvent.ACTION_DOWN)
					v.setBackgroundResource(R.drawable.mainmenuballtouched);
				else if (event.getAction() == MotionEvent.ACTION_UP)
					v.setBackgroundResource(R.drawable.mainmenuitem);
				return false;
			}
	
		};
		setCountry(LanguagePickActivity.Country);
		start =(TextView) findViewById(R.id.startGame);
        
        exit =(TextView) findViewById(R.id.exit);
		start.setOnTouchListener(l);
		
		exit.setOnTouchListener(l);
		
		
        }
	
	private void setCountry(int country){
		 		 		
		 switch (country) {
		 case LanguagePickActivity.MACEDONIAN:
			 LayoutInflater.from(this).inflate(R.layout.macedonianmainmenu, parent, true);
			 parent.setBackgroundResource(R.drawable.mkflag);
			 learn =(TextView) findViewById(R.id.learnMacedonian);
			 learn.setOnTouchListener(l);			 
			 title = (ImageView) findViewById(R.id.menuTitle);
			 title.setImageResource(R.drawable.macedonian_numbers_title);			 
			 break;
		 case LanguagePickActivity.SPANISH:
			 LayoutInflater.from(this).inflate(R.layout.redmainmenu, parent, true);
			 parent.setBackgroundResource(R.drawable.spanishflag);
			 more =(TextView) findViewById(R.id.moreGames);
			 title = (ImageView) findViewById(R.id.menuTitle);			
			 title.setImageResource(R.drawable.spanish_numbers_title);			 
			 more.setOnTouchListener(l);			 
			 break;		
		default:
			break;
		}
		 
	 }
	
	// TODO add more buttons. 
	//      more games in every language
	//      get pro in every language
	//      find more partner websites for other languages
	public void startGame(View v){
		Intent i = new Intent(this,LearningNumbersActivity.class);
		startActivity(i);
	}
	
	public void learnMacedonian(View v){
		String url = "http://www.learn-mk.com";
		Intent i = new Intent(Intent.ACTION_VIEW);
		i.setData(Uri.parse(url));
		startActivity(i);
	}
	
	public void moreGames(View v) { 
		String url = "https://play.google.com/store/apps/developer?id=gameower";
		Intent i = new Intent(Intent.ACTION_VIEW);
		i.setData(Uri.parse(url));
		startActivity(i);
	}
	public void exit(View v){
		finish();
	}
}
